<?php
/*
 * filename: submit.php
 * author: xuguoyu
 * date: 2010/4/22
 * update:
 * description: 
 */

require 'cls/base.php';

$tpl = new Template('t');
$tpl->setFile ( "main", "main.html" );
$tpl->setFile ( "submit", "submit.html" );
$tpl->setBlock ( "submit", "options", "optionss" );

$db = conn();

$id = fget("id");
if($id > 0){ //修改
	$sql = "select * from item where id={$id}";
	$rs=$db->query($sql);
	$v = $rs['0'];
	$tpl->setVar(array(
			"id" => $v['id'],
			"caption" => $v['caption'],
			"price" => $v['price'],
			"acount" => $v['amount'],
			"time" => $v['time'],
			"appraise" => $v['appraise'],
			"area" => $v['area'],
			"shop" => $v['shop_name'],
			"explain" => $v['explain'],
			"ac" => "edit"
			));
	$type = $v['type']; //类型值存为变量
}else{ //添加
	$tpl->setVar("ac", "add");
	$type = 0;
}

//类别列表
$sql = "select * from partition";
$rs=$db->query($sql);
foreach($rs as $v){
	$selected = $v['id'] == $type ? "selected" : "";
	$tpl->setVar(array("type_id" => $v['id'], "type_name" => $v['caption'], "selected" => $selected));
	$tpl->parse("optionss", "options", true);
}

$tpl->parse('main_content', 'submit');
$tpl->p("main");
?>